package com.ms.demo;

import org.junit.Test;

public class SpringProxyTest1 {


    @Test
    public void calculateStaticProxyTest(){
        CalculateImplStaticProxy staticProxy = new CalculateImplStaticProxy(new CalculateImpl());
        staticProxy.div(3,0);
    }


    @Test
    public void calculateImplJDkProxyTest(){
        CalculateJdkProxy calculateJdkProxy = new CalculateJdkProxy(new CalculateImpl());
        Calculate proxyObject = (Calculate)calculateJdkProxy.getProxyObject();
        proxyObject.add(1,2);
    }

    @Test
    public void calculateImplCglibProxyTest(){
        //传入一个目标对象
        CalculateCglibProxy cglibProxy = new CalculateCglibProxy(new CalculateImpl());
        //得到代理对象
        Calculate proxy = (Calculate)cglibProxy.getProxy();
        //调用代理对象
        proxy.add(1,2);
    }


}